;#############################
;命令：
;nasm -f elf64 day1_2for_0basic.asm -o main.o && gcc main.o -o main -lc -no-pie && ./main
;输出：
;This is 0 !!!
;This is 1 !!!
;This is 2 !!!
;This is 3 !!!
;This is 4 !!!
;#############################
extern printf

section .data
	msg: db `This is %d !!!\n`, 0
	x: dq 0                                         ;
	length: equ $ - msg

section .text
	global main

main:
	push rbp
	mov rbp, rsp

	;for (int i = 0; i < 5; ++i) {
	;    printf("This is %d !!!\n", i);
	;}
;###############################
	;compare段写在最下面
	;原因是跳出循环时好跑路
	mov ebx, 0
	jmp compare

execute:
	mov rdi, msg
	mov [x], ebx
	mov rsi, [x]
	call printf

	inc ebx

compare:
	cmp ebx, 5
	jl execute
;###############################

	mov eax, 0
	leave
	ret
